<?php
namespace app\user\controller;
use think\Db;
use think\Session;

Class Profile extends Common{
    protected $token = '_IdoNotKnowWhatTheKeyIs__LetMeGo';

    public function index(){
        $id = $this->admin['id'];
        $res = obj_decode($this->read($id));
        if($res['code']){
            $this->assign('admin',$res['data']);
        }
        else{
            exit('未找到相关人员！');
        }
        return $this->fetch();
    }

    public function edit(){
        $params = $this->params;
        $params['id'] = $this->admin['id'];
        $res = obj_decode( $this->update($params) );
        if($res['code']){
            Session::delete('admin');
            return_msg(1,'更新成功!',[],'/admin/member/login');
        }
        else{
            return_msg(0,'更新失败');
        }
    }


}
